<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <!--bootstrap-->
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/js/bootstrap/css/bootstrap.min.css" />
    <!--bootstrap-toastr-->
    <script type="text/javascript" src="/js/toastr/toastr.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/js/toastr/toastr.css" />
</head>
<body>
<form class="form-horizontal">
    <div class="form-group">

    </div>
    <div class="form-group">
        <label for="name" class="col-sm-2 control-label">节点名称</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" id="name" placeholder="请输入">
        </div>
    </div>
    <div class="form-group">
        <label for="url" class="col-sm-2 control-label">url</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" id="url" placeholder="url">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" class="btn btn-success" onclick="addMenu()">确定</button>
        </div>
    </div>
</form>
</body>
<script th:inline="javascript">
    function addMenu(){
        var menu = {
            "name" : $('#name').val(),
            "url" : $('#url').val(),
            "pid" : [[${nodeId}]]
        }
        var parameter = JSON.stringify(menu);
        $.ajax({
            url: "/menu",
            dataType: "json",
            contentType : 'application/json;charset=UTF-8',
            type: "post",
            // async: false,
            data: parameter,
            success: function (data) {
                // console.log(data);
                if (data.code == 200){
                    toastr.success("成功");
                    setTimeout(function () {
                        parent.location.reload();
                    }, 1000);
                    // alert("操作成功");
                    // var index = parent.layer.getFrameIndex(window.name);
                    // parent.layer.close(index);

                }
            },
            error: function (e) {
                alert("系统错误");
            }
        })
    }

</script>
</html>
